<template>
  <div class="box">
    <div class="top">
      <div class="title-box">
        <span class="title">男女比例</span>
        <img src="../../images/dataScreen-title.png" />
      </div>
    </div>
    <div class="sex">
      <div class="man">
        <span class="title">男士</span>
        <img src="../../images/man.png" />
      </div>
      <div class="woman">
        <span class="title">女士</span>
        <img src="../../images/woman.png" />
      </div>
    </div>

    <div class="rate">
      <div>男士60%</div>
      <div>女士40%</div>
    </div>
    <div class="chart" ref="chartRef"></div>
  </div>
</template>

<script setup lang="ts" name="sex">
import * as echarts from 'echarts'
import { onMounted, ref } from 'vue'

let chartRef = ref()
onMounted(() => {
  initChart()
})

const initChart = () => {
  const chart = echarts.init(chartRef.value)
  const option = {
    title: {
      text: '男女比例',
      textStyle: {
        color: '#fff',
      },
      left: '40%',
      bottom: '10%',
    },
    xAxis: {
      show: false,
      min: 0,
      max: 100,
    },
    yAxis: {
      show: false,
      type: 'category',
    },
    series: [
      {
        type: 'bar',
        data: [60],
        barWidth: 20,
        z: 100,
        itemStyle: {
          color: 'skyblue',
          borderRadius: [20],
        },
      },
      {
        type: 'bar',
        data: [100],
        barWidth: 20,
        barGap: '-100%',
        itemStyle: {
          color: 'pink',
          borderRadius: [20],
        },
      },
    ],
  }
  chart.setOption(option)
}
</script>

<style scoped lang="scss">
.box {
  width: 100%;
  height: 100%;
  background: url('../../images/dataScreen-main-lb.png') no-repeat;
  background-size: 100% 100%;
  margin-top: 20px;
  .title-box {
    margin-left: 20px;
    display: flex;
    flex-direction: column;

    .title {
      font-size: 20px;
      color: #fff;
    }
    img {
      margin-top: 7px;
      width: 68px;
      height: 7px;
    }
  }

  .sex {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    .man {
      margin: 20px;
      width: 111px;
      height: 115px;
      background: url('../../images/man-bg.png') no-repeat;
      background-size: 100% 100%;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      .title {
        color: white;
        margin-bottom: 35px;
      }
    }
    .woman {
      width: 111px;
      height: 115px;
      background: url('../../images/woman-bg.png') no-repeat;
      background-size: 100% 100%;
      margin: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      .title {
        color: white;
        margin-bottom: 35px;
      }
      img {
        width: 61px;
        height: 61px;
      }
    }
  }
  .rate {
    padding: 0 30px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 20px;
    color: #fff;
  }
  .chart {
    height: 100px;
    width: 100%;
  }
}
</style>
